Set panel title/aspect/frameon once per panel, not per render command#702
Open
timtreis wants to merge 1 commit into
Open
Set panel title/aspect/frameon once per panel, not per render command#702timtreis wants to merge 1 commit into
timtreis wants to merge 1 commit into
Conversation
…#695) In `show()`, the title/`set_aspect`/`axis("off")` block sat inside the `for cmd, params in render_cmds:` loop, so for a chained call (e.g. render_images().render_shapes()) these ran once per render command instead of once per panel, and the title-length `IndexError` check re-evaluated each iteration (so it could surface mid-loop rather than up front). Dedent the block one level so it runs once per panel after the per-command loop. Output is unchanged (the calls are idempotent) — verified byte-identical to main for single- and multi-command chains with title and frameon set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #695. In
PlotAccessor.show, the panel title /set_aspect("equal")/axis("off")block sat inside thefor cmd, params in render_cmds:loop (basic.py:~1797), so it ran once per render command instead of once per panel.For a chained call like
render_images().pl.render_shapes(...),ax.set_title(...)/set_aspect/axis("off")executed N times per panel, and the title-lengthIndexErrorcheck re-evaluated each iteration — so a mismatchedtitlelength could surface mid-render rather than up front.Fix
Dedent the block one level so it runs once per panel, after the per-command loop. That's the entire change — Python's indentation moves it out of the inner loop; it already uses only panel-level locals (
title,panel_key,cs,i,ax,fig_params).Verification
main(RGBA buffers compared vianp.array_equal) for a single-command plot and a 3-command chain withtitle=andframeon=Falseset — the calls are idempotent, so output is unchanged.No regression test added: the change removes redundant repeated calls with no observable output difference, so there's no new behavior to lock that the existing multi-panel-title visual tests (CI) don't already cover.
Note / possible follow-up
The issue also suggested validating
len(title) == num_panelsonce before the panel loop. That's left out here to keep the diff minimal — the per-panelIndexErrorstill fires (now once per panel). Happy to add the up-front validation if preferred.